/**
 * @author 橘柚
 * @Date 2023/11/22 20:34
 * @Description
 */

enum TimeOfDay {
  Morning = "早上",
  Afternoon = "下午",
  Evening = "晚上"
}

/**
 * 获取指定时间在当天的日段
 * @param date
 */
export const getDaySegment = (date: Date = new Date()): TimeOfDay => {
  const hour = date.getHours();

  if (hour >= 6 && hour < 12) {
    return TimeOfDay.Morning;
  } else if (hour >= 12 && hour < 18) {
    return TimeOfDay.Afternoon;
  } else {
    return TimeOfDay.Evening;
  }
}